package com.shy.springframework.test.bean;

import com.shy.springframework.beans.BeansException;
import com.shy.springframework.beans.factory.*;
import com.shy.springframework.context.ApplicationContext;
import com.shy.springframework.context.ApplicationContextAware;

/**
 * @author yzpang
 * @desc:
 * @date: 2023/2/7 13:43
 */
public class UserService implements InitializingBean, DisposableBean, BeanFactoryAware, BeanNameAware, BeanClassLoaderAware, ApplicationContextAware {
    private String uid;
    private String company;
    private String location;
    private UserDao userDao;

    public UserService() {
    }

    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }

    public String getCompany() {
        return company;
    }

    public void setCompany(String company) {
        this.company = company;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public UserDao getUserDao() {
        return userDao;
    }

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    public void queryUserInfo(){
        System.out.println("查询用户信息: uid:" + uid + ",name:" + userDao.queryUserName(uid)
            + ",company:" + company + ",location:" + location);
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("userService执行销毁方法");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("userService执行初始化方法");
    }

    @Override
    public void setBeanClassLoader(ClassLoader classLoader) throws BeansException {
        System.out.println("classLoader: " + classLoader);
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        System.out.println("beanFactory: " + beanFactory);
    }

    @Override
    public void setBeanName(String beanName) throws BeansException {
        System.out.println("beanName: " + beanName);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        System.out.println("applicationContext: " + applicationContext);
    }
}
